import Taro, { Component, Config } from "@tarojs/taro";
import 'promise-prototype-finally';
import "./app.scss";
import Auth from "./utils/auth";
import { Index } from "./pages/index";

// export const store = configStore();
class App extends Component<any, any> {
  /**
   * 指定config的类型声明为: Taro.Config
   * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
   * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
   * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
   */
  config: Config = {
    pages: [
      "pages/index/index",
      "pages/user/index",
    ],
    subPackages: [
      {
        root: "packages/package-records",
        pages: ["index"],
        name: "记录",
        independent: false
      },
      {
        root: "packages/package-uglify",
        pages: ["index"],
        name: "压缩图片demo",
        independent: false
      }
    ],
    window: {
      backgroundTextStyle: "light",
      navigationBarBackgroundColor: "#fff",
      navigationBarTitleText: "WeChat",
      navigationBarTextStyle: "black"
    },
    tabBar: {
      color: "#888888",
      selectedColor: "#ffbb00",
      list: [
        {
          pagePath: "pages/index/index",
          iconPath: "./assets/tab-bar/首页.png",
          selectedIconPath: "./assets/tab-bar/首页选中.png",
          text: "首页"
        },

        {
          pagePath: "pages/user/index",
          iconPath: "./assets/tab-bar/图鉴.png",
          selectedIconPath: "./assets/tab-bar/图鉴选中.png",
          text: "图鉴"
        }
      ]
    },
    usingComponents: {},
    permission: {
      "scope.userLocation": {
        desc: "你的位置信息将用于小程序位置接口的效果展示"
      }
    },
    preloadRule: {}
  };

  componentDidMount() {
    // 检查session_key 是否过期
    Auth.appCheckSessionKey();
  }

  componentDidCatchError() { }

  // 在 App 类中的 render() 函数没有实际作用
  // 请勿修改此函数
  render() {
    return (
      <Index />
    );
  }
}

Taro.render(<App />, document.getElementById("app"));
